{literal}
	<script	src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<script	src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
	
	<script type="text/javascript">
		$(document).ready(function(){
		var col = "{/literal}{$orderby}{literal}";
		var order = "{/literal}{$order}{literal}";
		$(".sortImage").attr("src","images/sort_both.png");
		if (order=="desc")
			$("#sort"+col).attr("src","images/sort_desc.png");
		else if (order=="asc")
			$("#sort"+col).attr("src","images/sort_asc.png");
		})		 

	    $(function(){
			$('.date-pick').datePicker();
	    });
	</script>
{/literal}

<div class="grid_10">
	<div class="box round first grid">
	   	<h2>Administraci&oacute;n de noticias</h2>
	   	<div class="clear"></div>
	   	
		<!-- Opciones generales -->
		<div style="padding-top:10px">
			{if $rol|strpos:"0" !== false || $rol|strpos:"Lw" !== false}
				<div class="submenuImage"><img width="26px" src="images/new.png"/></div>
				<div class="submenuTitle"><a style="margin-right:20px;" href="noticias.php?action=add">Agregar Noticia</a></div>
				<div style="clear:both"></div>
			{/if}
		</div>
		<div class="clear"></div>

		{include file="noticiasSearch.tpl"} 

		<!-- Item list -->
		<div class="block">
			<form id="formNoticia" method="POST" action="noticias.php" class="list">
			    <input type="hidden" id="sortby" name="sortby"/>
				<input type="hidden" id="order" name="order"/>
				<input type="hidden" id="action" name="action" value=""/>
				<input type="hidden" id="id" name="id" value=""/>
				<table class="table1">
					<tr>
						<th>
							<a href="#" onclick="ordenar('Fecha','formNoticiasSearch')">
								<img id="sortFecha" class="sortImage" src="images/sort_desc.png">
								Fecha
							</a>
						</th>
						<th>
							<a href="#" onclick="ordenar('Titulo','formNoticiasSearch')">
								<img id="sortTitulo" class="sortImage" src="images/sort_desc.png">
								T&iacute;tulo
							</a>
						</th>
						<th>
							<a href="#" onclick="ordenar('Categoria','formNoticiasSearch')">
								<img id="sortCategoria" class="sortImage" src="images/sort_desc.png">
								Categor&iacute;a
							</a>
						</th>
						<th width="90px;">
							<a href="#" onclick="ordenar('Activo','formNoticiasSearch')">
								<img id="sortTitulo" class="sortImage" src="images/sort_desc.png">
								Destacada
							</a>
						</th>
						<th width="100px;">
							<a href="#" onclick="ordenar('Orden','formNoticiasSearch')">
								<img id="sortTitulo" class="sortImage" src="images/sort_desc.png">
								Orden
							</a>
						</th>
						<th width="145px;">
							&nbsp;
						</th>					
					</tr>
					{if $cantidad eq 0}
						<tr>
							<td class="item no-results" colspan="8">No existen noticias</td>
						</tr>
					{/if}
					{foreach from=$noticias item=noticia}
						<tr style="height:30px" class="odd gradeX">
							<td class="item">{$noticia.fecha|date_format:"%d-%m-%Y"}</td>
							<td class="item">{$noticia.titulo}</td>
							<td class="item">{$noticia.categoria}</td>
							<td class="item" align="center"> 
								{if $noticia.activo}
									<a href="noticias.php?action=desactivar&id={$noticia.id}" >
										<img src="images/publish.png" width="20px" alt="Desactivar" title="Desactivar"/>
									</a>
								{/if}
								{if !$noticia.activo}
									<a href="noticias.php?action=activar&id={$noticia.id}" >	
										<img src="images/nopublish.png" width="20px" alt="Activar" title="Activar"/>
									</a>
								{/if}
							</td>
							<td class="item" align="center">{if $noticia.orden == 99}Sin prioridad{else}{$noticia.orden}{/if}</td>
							<td align="left" class="item options">
								<a href="noticias.php?action=detail&id={$noticia.id}" >
									<img width="20px" src="images/b_details.png" alt="Detalle" title="Detalle" style="padding-right:5px"/>
								</a>						
								{if $rol|strpos:"0" !== false || $rol|strpos:"Lw" !== false}
									<a href="noticias.php?action=update&id={$noticia.id}" >
										<img  width="20px"  src="images/b_edit2.png" alt="Editar" title="Editar" style="padding-right:5px"/>
									</a>
								{/if}
								{if $rol|strpos:"0" !== false || $rol|strpos:"Lw" !== false}
									<a href="#" onclick="deleteNoticia({$noticia.id},'formNoticia')" >
										<img width="20px"   src="images/b_remove.png" alt="Borrar" title="Borrar" style="padding-right:5px"/>
									</a>
								{/if}
								<a style="color:#444" href="imagenes.php?iditem={$noticia.id}&t=noticias">
									<img  width="20px"  src="images/picture.png" title="Imagenes"/> {$noticia.imagecount}
								</a>&nbsp;
							</td>	
						</tr>	
					{/foreach}
				</table>
				{include file="paginator.tpl" page=$page totalPages=$totalPages script="noticias.php?action=page&$allParams"}
			</form>
		</div>
	</div>
</div>
